package com.jxb;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/10/27 16:17
 **/
public class TestParseToken {

    public static void main(String[] args) {
        //token
        String token ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzAwMjIyNDYsInVzZXJfbmFtZSI6ImZveCIsImF1dGhvcml0aWVzIjpbIlN5c3RlbUNvbnRlbnREZWxldGUiLCJTeXN0ZW1Vc2VyVmlldyIsIlN5c3RlbVVzZXIiLCJTeXN0ZW1Vc2VySW5zZXJ0IiwiU3lzdGVtVXNlckRlbGV0ZSIsIlN5c3RlbVVzZXJVcGRhdGUiLCJTeXN0ZW1Db250ZW50SW5zZXJ0IiwiU3lzdGVtQ29udGVudFVwZGF0ZSIsIlN5c3RlbUNvbnRlbnRWaWV3IiwiU3lzdGVtIiwiU3lzdGVtQ29udGVudCJdLCJqdGkiOiJlYTBiMzA1ZC0zMTFiLTQzZDYtYmU2Yy05ODMzYWM4NGJkODMiLCJjbGllbnRfaWQiOiJ3ZW5qaWFuIiwic2NvcGUiOlsiYWxsIl19.GWOR8xWyGLGKv2hod84fj-vgKpOy2VSSx1kve_RD2H8";
        //解析token获取载荷中申明的对象
        Claims claims = Jwts.parser()
                .setSigningKey("123123")
                .parseClaimsJws(token)
                .getBody();

        System.out.println("id:"+claims.getId());
        System.out.println("subject:"+claims.getSubject());
        System.out.println("issuedAt:"+claims.getIssuedAt());
    }

}
